<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>angularJs事件指令</title>
    <meta name="Copyright" content="All Rights Reserved"/>
    <link rel="shortcut icon" type="image/x-icon" href="itcast.ico"/>
    <link rel="stylesheet" type="text/css" href="base.css"/>
    <script src="js/angular.min.js"></script>
    <script type="text/javascript">
        /**
         * 定义模块
         */
        var myApp = angular.module("myApp",[]);

        /**
         * 模块中添加控制器
         */
        myApp.controller("myController",function ($scope) {
            /**
             * 定义方法
             */
            $scope.add = function () {
                $scope.count = parseInt($scope.x) + parseInt($scope.y);
            }

            /**
             * 定义方法
             */
            $scope.blur = function () {
                alert($scope.x);
            }

            /**
             * 定义方法
             */
            $scope.keyup = function () {
                alert($scope.y);
            }
        })

    </script>
</head>
<!-- 指定AngularJS应用的根元素 -->
<body ng-app="myApp" ng-controller="myController">
    x值：<input type="text" ng-model="x" ng-blur="blur();"/><br/>
    y值：<input type="text"ng-model="y" ng-keyup="keyup()"/><br/>
    <input type="button" value="计算" ng-click="add();"/>
    <hr/>
    计算结果：{{count}}
</body>
</html>